﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace 文件浏览
{
    public partial class 创建和删除目录_文件夹_ : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                //判断如果选择的是创建目录
                if (RadioButtonList1.SelectedValue == "创建")
                {
                    //创建目录
                    Directory.CreateDirectory(TextBox1.Text);
                    Label1.Text = "*创建成功*" + " \n" + " 创建时间:" + Directory.GetCreationTime(TextBox1.Text) + "\n" +
                        "父目录:" + Directory.GetParent(TextBox1.Text).FullName;
                }

                else //否则执行删除目录操作
                {
                    if (Directory.Exists(TextBox1.Text))
                    {
                        Directory.Delete(TextBox1.Text); //删除目录
                        Label1.Text = "目录删除成功!";
                    }
                    else
                    {
                        Label1.Text = "此目录不存在!";
                    }
                }
            }
            catch (Exception e1)
            {
                Label1.Text = e1.Message;
            }
        }
    }

}